package com.ztz.musicappdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ztz.musicappdemo.R;
import com.ztz.musicappdemo.bean.Music;

import java.util.List;

/**
 * Created by wqewqe on 2017/4/11.
 */

public class MusicLVadapter extends BaseAdapter {
    Context context;
    List<Music> musicList;

    public MusicLVadapter(Context context, List<Music> musicList) {
        this.context = context;
        this.musicList = musicList;
    }

    @Override
    public int getCount() {
        return musicList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
       return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
       View view= LayoutInflater.from(context).inflate(R.layout.item_music,parent,false);
        TextView tvPosition=(TextView)view.findViewById(R.id.item_id);
        TextView tvTitle=(TextView)view.findViewById(R.id.tv_title);
        TextView tvArtist=(TextView)view.findViewById(R.id.tv_artist);
        tvPosition.setText(""+musicList.get(position).getPosition());
        tvTitle.setText(musicList.get(position).getTitle());
        tvArtist.setText(musicList.get(position).getArtist());
        return view;
    }
}
